/*
 * Copyright (C) 2021 Realtek Semiconductor Corp.
 * All Rights Reserved.
 *
 * This program is the proprietary software of Realtek Semiconductor
 * Corporation and/or its licensors, and only be used, duplicated,
 * modified or distributed under the authorized license from Realtek.
 *
 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
 *
 * Purpose : Definition of ME handler: XG-PON TC performance monitoring history data (344)
 *
 * Feature : The file includes the following modules and sub-modules
 *           (1) ME handler: XG-PON TC performance monitoring history data (344)
 */

#include "app_basic.h"
#ifndef OMCI_X86
#include "rtk/stat.h"
#endif

MIB_TABLE_INFO_T gMibXgponTcPmTableInfo;
MIB_ATTR_INFO_T  gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ATTR_NUM];
MIB_TABLE_XGPONTCPMHD_T gMibXgponTcPmDefRow;
MIB_TABLE_OPER_T gMibXgponTcPmOper;

static UINT8    aXgponTcPmTcaAlmNumber[MIB_TABLE_XGPONTCPMHD_ATTR_NUM];
static UINT8    aXgponTcPmTcaAttrMap[MIB_TABLE_XGPONTCPMHD_ATTR_NUM];


GOS_ERROR_CODE XGPON_TC_pm_CfgMe(void* pOldRow, void* pNewRow, MIB_OPERA_TYPE operationType, MIB_ATTRS_SET attrSet, UINT32 pri)
{
    GOS_ERROR_CODE                  ret;
    UINT32                          entrySize;
    MIB_TABLE_INDEX                 tableIndex;
    MIB_TABLE_ANIG_T                mibAniG;
    MIB_TABLE_XGPONTCPMHD_T         mibCurrentBin;
    MIB_TABLE_XGPONTCPMHD_T        *pMibXgponTcPmhd;


    pMibXgponTcPmhd = (MIB_TABLE_XGPONTCPMHD_T *)pNewRow;

    // check if corresponding ANI-G exists
    mibAniG.EntityID = pMibXgponTcPmhd->EntityId;
    ret = MIB_Get(MIB_TABLE_ANIG_INDEX, &mibAniG, sizeof(MIB_TABLE_ANIG_T));
    if (GOS_OK != ret)
    {
        OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Instance not found in %s: %s, 0x%x",
            __FUNCTION__, MIB_GetTableName(MIB_TABLE_ANIG_INDEX), mibAniG.EntityID);

        return GOS_FAIL;
    }


    tableIndex = MIB_TABLE_XGPON_TC_PMHD_INDEX;
    entrySize = MIB_GetTableEntrySize(tableIndex);

    switch (operationType)
    {
        case MIB_ADD:
            // sync control block data from history bin to current bin
            if (GOS_OK != MIB_SetPmCurrentBin(tableIndex, pMibXgponTcPmhd, entrySize))
            {
                OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Set current bin error in %s: %s, 0x%x",
                    __FUNCTION__, MIB_GetTableName(tableIndex), pMibXgponTcPmhd->EntityId);
            }

            ret = mib_alarm_table_add(tableIndex, pNewRow);
            break;

        case MIB_DEL:
            ret = mib_alarm_table_del(tableIndex, pOldRow);
            break;

        case MIB_SET:
            mibCurrentBin.EntityId = pMibXgponTcPmhd->EntityId;
            if (GOS_OK != MIB_GetPmCurrentBin(tableIndex, &mibCurrentBin, entrySize))
            {
                OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Current bin not found in %s: %s, 0x%x",
                    __FUNCTION__, MIB_GetTableName(tableIndex), mibCurrentBin.EntityId);

                return GOS_FAIL;
            }

            // sync control block data from history bin to current bin
            mibCurrentBin.ThresholdID = pMibXgponTcPmhd->ThresholdID;
            if (GOS_OK != MIB_SetPmCurrentBin(tableIndex, &mibCurrentBin, entrySize))
            {
                OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Set current bin error in %s: %s, 0x%x",
                    __FUNCTION__, MIB_GetTableName(tableIndex), mibCurrentBin.EntityId);
            }
            break;

        default:
            break;
    }

    return ret;
}

GOS_ERROR_CODE XGPON_TC_pm_handler(MIB_TABLE_INDEX        tableIndex,
                                                omci_me_instance_t      instanceID,
                                                omci_pm_oper_type_t     operType,
                                                BOOL                    *pIsTcaRaised)
{
    GOS_ERROR_CODE                  ret;
    UINT32                          entrySize;
    MIB_TABLE_ANIG_T                mibAniG;
    MIB_TABLE_XGPONTCPMHD_T         mibXgponTcPm;
    MIB_TABLE_XGPONTCPMHD_T         mibCurrentBin;
    omci_xgpon_stat_t               portCntrs;
    omci_xgpon_stat_t               *pPortCntrs = (omci_xgpon_stat_t*)&portCntrs;

    if (!pIsTcaRaised)
        return GOS_ERR_PARAM;

    // get table entry size
    entrySize = MIB_GetTableEntrySize(tableIndex);

    mibAniG.EntityID = instanceID;
    if (GOS_OK != MIB_Get(MIB_TABLE_ANIG_INDEX, &mibAniG, sizeof(MIB_TABLE_ANIG_T)))
    {
        OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Instance not found in %s: %s, 0x%x",
            __FUNCTION__, MIB_GetTableName(MIB_TABLE_ANIG_INDEX), mibAniG.EntityID);

        return GOS_FAIL;
    }

    mibXgponTcPm.EntityId = instanceID;
    if (GOS_OK != MIB_Get(tableIndex, &mibXgponTcPm, entrySize))
    {
        OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Instance not found in %s: %s, 0x%x",
            __FUNCTION__, MIB_GetTableName(tableIndex), instanceID);

        return GOS_FAIL;
    }

    mibCurrentBin.EntityId = instanceID;
    if (GOS_OK != MIB_GetPmCurrentBin(tableIndex, &mibCurrentBin, entrySize))
    {
        OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Current bin not found in %s: %s, 0x%x",
            __FUNCTION__, MIB_GetTableName(tableIndex), instanceID);

        return GOS_FAIL;
    }

    if (OMCI_PM_OPER_RESET == operType)
    {
        memset(&mibCurrentBin, 0, entrySize);
        mibCurrentBin.EntityId = instanceID;
        mibCurrentBin.ThresholdID = mibXgponTcPm.ThresholdID;

        if (GOS_OK != MIB_SetPmCurrentBin(tableIndex, &mibCurrentBin, entrySize))
        {
            OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Set current bin error in %s: %s, 0x%x",
                __FUNCTION__, MIB_GetTableName(tableIndex), instanceID);
        }

        if (GOS_OK != MIB_Set(tableIndex, &mibCurrentBin, entrySize))
        {
            OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Set instance error in %s: %s, 0x%x",
                __FUNCTION__, MIB_GetTableName(tableIndex), instanceID);
        }

        return GOS_OK;
    }

    if(OMCI_PM_OPER_GET_CURRENT_DATA == operType)
    {
        omci_pm_update_xgpon_stat(OMCI_PM_OPER_GET_CURRENT_DATA, OMCI_XGPON_PM_BITMAP_TC);
    }


    if (OMCI_PM_OPER_UPDATE == operType ||
        OMCI_PM_OPER_UPDATE_AND_SWAP == operType ||
        OMCI_PM_OPER_GET_CURRENT_DATA == operType)

    {
        // update PM values
        if (GOS_OK == omci_pm_getCurrent_xgpon_stat(instanceID,pPortCntrs))
        {
            m_omci_pm_update_reset_u32_attr(pPortCntrs->psbdHecErrCnt, mibCurrentBin.PsbdHecErrCnt);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->xgtcHecErrCnt, mibCurrentBin.XgtcHecErrCnt);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->unknownProfileCnt, mibCurrentBin.UnknownProfileCnt);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->transXgponEncMethodXgemFrames, mibCurrentBin.TransXgponEncMethodXgemFrames);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->fragmentXgemFrames, mibCurrentBin.FragmentXgemFrames);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->xgemHecLostWordsCnt, mibCurrentBin.XgemHecLostWordsCnt);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->xgemKeyErrors, mibCurrentBin.XgemKeyErrors);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->xgemHecErrorCnt, mibCurrentBin.XgemHecErrorCnt);
            m_omci_pm_update_reset_u64_attr(pPortCntrs->transBytesInNonidleXGEMFrames, mibCurrentBin.TransBytesInNonidleXGEMFrames);
            m_omci_pm_update_reset_u64_attr(pPortCntrs->recvBytesInNonidleXGEMFrames, mibCurrentBin.RecvBytesInNonidleXGEMFrames);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->LODSEventCnt, mibCurrentBin.LODSEventCnt);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->LODSEventRestoredCnt, mibCurrentBin.LODSEventRestoredCnt);
            m_omci_pm_update_reset_u32_attr(pPortCntrs->onuReactivationByLODSEvents, mibCurrentBin.OnuReactivationByLODSEvents);
        }


        if (GOS_OK != MIB_SetPmCurrentBin(tableIndex, &mibCurrentBin, entrySize))
        {
            OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Set current bin error in %s: %s, 0x%x",
                __FUNCTION__, MIB_GetTableName(tableIndex), instanceID);
        }

        ret = omci_pm_is_threshold_crossed(tableIndex, instanceID,
                &mibCurrentBin, aXgponTcPmTcaAlmNumber, aXgponTcPmTcaAttrMap, NULL, pIsTcaRaised);
        if (GOS_OK != ret && GOS_ERR_NOT_FOUND != ret)
        {
            OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Check threshold error in %s: %s, 0x%x",
                __FUNCTION__, MIB_GetTableName(tableIndex), instanceID);
        }
    }

    if (OMCI_PM_OPER_SWAP == operType || OMCI_PM_OPER_UPDATE_AND_SWAP == operType)
    {
        // swap PM values
        mibCurrentBin.IntEndTime++;
        mibXgponTcPm.IntEndTime = mibCurrentBin.IntEndTime;

        if (GOS_OK != MIB_Set(tableIndex, &mibCurrentBin, entrySize))
        {
            OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Set instance error in %s: %s, 0x%x",
                __FUNCTION__, MIB_GetTableName(tableIndex), instanceID);
        }

        memset(&mibCurrentBin, 0, entrySize);
        mibCurrentBin.EntityId = instanceID;
        mibCurrentBin.ThresholdID = mibXgponTcPm.ThresholdID;
        mibCurrentBin.IntEndTime = mibXgponTcPm.IntEndTime;

        if (GOS_OK != MIB_SetPmCurrentBin(tableIndex, &mibCurrentBin, entrySize))
        {
            OMCI_LOG(OMCI_LOG_LEVEL_ERR, "Set current bin error in %s: %s, 0x%x",
                __FUNCTION__, MIB_GetTableName(tableIndex), instanceID);
        }
    }

    return GOS_OK;
}

GOS_ERROR_CODE mibTable_init(MIB_TABLE_INDEX tableId)
{
    if(!IS_G987_SYSTEM())
    {
        OMCI_PRINT("Ignore classId:%d,only support on G.987 ONU", OMCI_ME_CLASS_XGPON_TC_PMHD);
        return GOS_FAIL;
    }

    gMibXgponTcPmTableInfo.Name = "XgponTcPm";
    gMibXgponTcPmTableInfo.ShortName = "XGPONTCPMHD";
    gMibXgponTcPmTableInfo.Desc = " XG-PON TC performance monitoring history data ";
    gMibXgponTcPmTableInfo.ClassId = (UINT32)(OMCI_ME_CLASS_XGPON_TC_PMHD);
    gMibXgponTcPmTableInfo.InitType = (UINT32)(OMCI_ME_INIT_TYPE_OLT);
    gMibXgponTcPmTableInfo.StdType = (UINT32)(OMCI_ME_TYPE_STANDARD_PM);
    gMibXgponTcPmTableInfo.ActionType = (UINT32)(OMCI_ME_ACTION_CREATE | OMCI_ME_ACTION_DELETE | OMCI_ME_ACTION_SET | OMCI_ME_ACTION_GET | OMCI_ME_ACTION_GET_CURRENT_DATA);
    gMibXgponTcPmTableInfo.pAttributes = &(gMibXgponTcPmAttrInfo[0]);

    gMibXgponTcPmTableInfo.attrNum = MIB_TABLE_XGPONTCPMHD_ATTR_NUM;
    gMibXgponTcPmTableInfo.entrySize = sizeof(MIB_TABLE_XGPONTCPMHD_T);
    gMibXgponTcPmTableInfo.pDefaultRow = &gMibXgponTcPmDefRow;

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Name = "EntityId";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].Name = "IntEndTime";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].Name = "ThresholdID";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].Name = "PsbdHecErrCnt";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].Name = "XgtcHecErrCnt";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].Name = "UnknownProfileCnt";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Name = "TransXgponEncMethodXgemFrames";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Name = "FragmentXGEMFrames";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].Name = "XgemHecLostWordsCnt";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].Name = "XgemKeyErrors";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].Name = "XgemHecErrorCnt";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Name = "TransBytesInNonidleXgemFrames";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Name = "RecvBytesInNonidleXgemFrames";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].Name = "LODSEventCnt";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].Name = "LODSEventRestoredCnt";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].Name = "OnuReactivationByLODSEvents";

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Entity ID";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Interval End Time";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Threshold Data ID";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "PSBd HEC error count";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "XGTC HEC error count";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Unknown profile count";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Transmitted XG-PON encapsulation method (XGEM) frames";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Fragment XGEM frames";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "XGEM HEC lost words count";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "XGEM key errors";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "XGEM HEC error count";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Transmitted  bytes  in  non-idle  XGEM  frames";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Received bytes in non-idle XGEM frames";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Loss  of  downstream  synchronization  (LODS)  event  count";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "LODS event restored count";
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "ONU  reactivation  by  LODS  events";

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT64;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT64;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT32;

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].Len = 1;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Len = 8;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].Len = 8;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].Len = 4;

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = TRUE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = FALSE;

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_SBC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;

    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_INTENDTIME_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_THRESHOLDID_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSXGPONENCMETHODFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_FRAGXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_TRANSBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_RECVBYTESINNONIDELXGEMFRAMES_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTCNT_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_LODSEVENTRESTOREDCNT_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);
    gMibXgponTcPmAttrInfo[MIB_TABLE_XGPONTCPMHD_ONUREACTIVATIONBYLODSEVENTS_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = (OMCI_ME_ATTR_TYPE_MANDATORY | OMCI_ME_ATTR_TYPE_PM);

    memset(&(gMibXgponTcPmDefRow.EntityId), 0x00, sizeof(gMibXgponTcPmDefRow.EntityId));
    memset(&(gMibXgponTcPmDefRow.IntEndTime), 0x00, sizeof(gMibXgponTcPmDefRow.IntEndTime));
    memset(&(gMibXgponTcPmDefRow.ThresholdID), 0x00, sizeof(gMibXgponTcPmDefRow.ThresholdID));
    memset(&(gMibXgponTcPmDefRow.PsbdHecErrCnt), 0x00, sizeof(gMibXgponTcPmDefRow.PsbdHecErrCnt));
    memset(&(gMibXgponTcPmDefRow.XgtcHecErrCnt), 0x00, sizeof(gMibXgponTcPmDefRow.XgtcHecErrCnt));
    memset(&(gMibXgponTcPmDefRow.UnknownProfileCnt), 0x00, sizeof(gMibXgponTcPmDefRow.UnknownProfileCnt));
    memset(&(gMibXgponTcPmDefRow.TransXgponEncMethodXgemFrames), 0x00, sizeof(gMibXgponTcPmDefRow.TransXgponEncMethodXgemFrames));
    memset(&(gMibXgponTcPmDefRow.FragmentXgemFrames), 0x00, sizeof(gMibXgponTcPmDefRow.FragmentXgemFrames));
    memset(&(gMibXgponTcPmDefRow.XgemHecLostWordsCnt), 0x00, sizeof(gMibXgponTcPmDefRow.XgemHecLostWordsCnt));
    memset(&(gMibXgponTcPmDefRow.XgemKeyErrors), 0x00, sizeof(gMibXgponTcPmDefRow.XgemKeyErrors));
    memset(&(gMibXgponTcPmDefRow.XgemHecErrorCnt), 0x00, sizeof(gMibXgponTcPmDefRow.XgemHecErrorCnt));
    memset(&(gMibXgponTcPmDefRow.TransBytesInNonidleXGEMFrames), 0x00, sizeof(gMibXgponTcPmDefRow.TransBytesInNonidleXGEMFrames));
    memset(&(gMibXgponTcPmDefRow.RecvBytesInNonidleXGEMFrames), 0x00, sizeof(gMibXgponTcPmDefRow.RecvBytesInNonidleXGEMFrames));
    memset(&(gMibXgponTcPmDefRow.LODSEventCnt), 0x00, sizeof(gMibXgponTcPmDefRow.LODSEventCnt));
    memset(&(gMibXgponTcPmDefRow.LODSEventRestoredCnt), 0x00, sizeof(gMibXgponTcPmDefRow.LODSEventRestoredCnt));
    memset(&(gMibXgponTcPmDefRow.OnuReactivationByLODSEvents), 0x00, sizeof(gMibXgponTcPmDefRow.OnuReactivationByLODSEvents));


    memset(&gMibXgponTcPmOper, 0x0, sizeof(MIB_TABLE_OPER_T));
	gMibXgponTcPmOper.meOperDrvCfg = XGPON_TC_pm_CfgMe;
    gMibXgponTcPmOper.meOperConnCfg = NULL;
	gMibXgponTcPmOper.meOperConnCheck = NULL;
	gMibXgponTcPmOper.meOperAvlTreeAdd = NULL;
    gMibXgponTcPmOper.meOperDump = omci_mib_oper_dump_default_handler;
    gMibXgponTcPmOper.meOperPmHandler = XGPON_TC_pm_handler;

    // for PM ME only, indicates the Threshold value attribute mapping and alarm number
    memset(aXgponTcPmTcaAlmNumber, 0, sizeof(aXgponTcPmTcaAlmNumber));
    aXgponTcPmTcaAlmNumber[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX] = 0;
    aXgponTcPmTcaAlmNumber[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX] = 1;
    aXgponTcPmTcaAlmNumber[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX] = 2;
    aXgponTcPmTcaAlmNumber[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX] = 3;
    aXgponTcPmTcaAlmNumber[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX] = 4;
    aXgponTcPmTcaAlmNumber[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX] = 5;

    memset(aXgponTcPmTcaAttrMap, 0, sizeof(aXgponTcPmTcaAttrMap));
    aXgponTcPmTcaAttrMap[MIB_TABLE_XGPONTCPMHD_PSBDHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX] = 1;
    aXgponTcPmTcaAttrMap[MIB_TABLE_XGPONTCPMHD_XGTCHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX] = 2;
    aXgponTcPmTcaAttrMap[MIB_TABLE_XGPONTCPMHD_UNKNOWNPROFILECNT_INDEX - MIB_TABLE_FIRST_INDEX] = 3;
    aXgponTcPmTcaAttrMap[MIB_TABLE_XGPONTCPMHD_XGEMHECLOSTWORDSCNT_INDEX - MIB_TABLE_FIRST_INDEX] = 4;
    aXgponTcPmTcaAttrMap[MIB_TABLE_XGPONTCPMHD_XGEMKEYERR_INDEX - MIB_TABLE_FIRST_INDEX] = 5;
    aXgponTcPmTcaAttrMap[MIB_TABLE_XGPONTCPMHD_XGEMHECERRCNT_INDEX - MIB_TABLE_FIRST_INDEX] = 6;

    MIB_TABLE_XGPON_TC_PMHD_INDEX = tableId;
    MIB_InfoRegister(tableId, &gMibXgponTcPmTableInfo, &gMibXgponTcPmOper);

    return GOS_OK;
}
